package com.sy.core.exception;

/**
 * 自定义的 返回码枚举类
 * @ClassName: ErrorCode
 * @Description: TODO
 * @Date:2019/8/8 0008 10:39
 * @Version:1.0.1
 */
public enum ErrorCode {

    SERVER_SUCCESS("200","操作成功"),
    SERVER_LOGIN_ERROR("401","TOKEN过期"),
    SERVER_PARAMS_ERROR("402","参数异常"),
    SERVER_INTER_ERROR("408","接口信息异常"),
    SERVER_NO_PERMISSIONS("409","您无权进行此操作");

    private String code;

    private String message;

    ErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ErrorCode statOf(String code) {
        for (ErrorCode state : values())
            if (state.getCode().equals(code))
                return state;
        return null;
    }
}
